<template>
  <div>
      <el-dialog   :modelValue="dialogVisible"  title="选点"  width="50%"
                  :close-on-click-modal="false" :close-on-press-escape="false"
                  :show-close="false" >

        <el-form :model="datitem" label-width="120px"   >
          <el-form-item label="数据服务器编号">
            <el-input v-model="datitem.serverId"  style="width: 80%"></el-input>
          </el-form-item>
          
          <el-form-item label="数据平面编号">
            <el-input v-model="datitem.dbid"  style="width: 80%"></el-input>
          </el-form-item>
          
          <el-form-item label="关键字词">
            <el-input v-model="datitem.key"  style="width: 80%"></el-input>
          </el-form-item>

          <el-form-item label="数据描述">
            <el-input v-model="datitem.descr"  style="width: 80%"></el-input>
          </el-form-item>          
          
          <el-form-item label="显示字段">
            <el-select v-model="datitem.field" placeholder="请选择">
              <el-option label="value" value="value"></el-option>
            </el-select>
          </el-form-item>

          <el-form-item label="">
            <el-button @click="handleSearch" >搜索取点</el-button>
          </el-form-item>          
          
          <DlgSearchKey  ref="refDlgSearch" :dialog-visible="dlgVisibleSearch" @res-search-item="handleResSearch"></DlgSearchKey>

        </el-form>

        <template #footer>
          <div style="display: flex; flex-direction: row-reverse; ">
            <el-button @click="handleCancel">取消</el-button>
            <el-button type="primary" @click="handleOk"  style="margin: 0 10px 0 10px;" >确定</el-button>
          </div>
        </template>
      </el-dialog>
  </div>
</template>

<script>

import {ElMessage} from "element-plus";
import DlgSearchKey from "./DlgSearchKey.vue";

export default {
  name: "DlgSelectItem",
  props:{ dialogVisible: Boolean },
  components:{DlgSearchKey},
  emits:[ "resSelectItem" ],

  mounted() {

  },
  computed:{

  },
  data(){
    return{
      datitem : {  },
      dlgVisibleSearch: false ,
    }
  },
  watch: {

  },
  methods:{
    init( dat ){
      this.datitem = JSON.parse( JSON.stringify(dat)  )
    },

    handleOk(  ){
      this.$emit( "resSelectItem", 1, this.datitem )
    },

    handleCancel(){
      this.$emit( "resSelectItem", 0, this.datitem  )
    },

    handleSearch(  ){
        // this.$refs.refDlgSearch.init( )
        this.dlgVisibleSearch = true
    },  

    handleResSearch( code, res ){
      if(code === 0){
        this.dlgVisibleSearch = false
        return
      }
      this.datitem.key = res.key
      this.datitem.descr = res.descr
      this.datitem.dbid = res.dbid
      this.dlgVisibleSearch = false
    },  

  },  // end of methods

}

</script>

<style  lang="less" scoped >

// ::v-deep(.el-dialog){
//   .el-dialog__body {
//       height: 50vh; overflow: auto; padding: 0px;
//   }

//   .el-dialog__header{
//     margin: 0;
//     background-color: @dialog_header_color;
//   }

//   .el-dialog__footer {
//     background-color: @dialog_footer_color;
//   }
// }

::v-deep( tbody tr:hover > td ){
  background-color: transparent !important;
}

</style>